package com.geek.netty;

import com.geek.netty.inbound.HttpInboundServer;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.util.ArrayList;
import java.util.List;

@SpringBootApplication
public class NettyServerApplication {

    public final static String GATEWAY_NAME = "NIOGateway";

    public final static String GATEWAY_VERSION = "3.0.0";

    public final static int port = 8888;

    public static void main(String[] args) {
        // 代理的url
        List proxyServices = new ArrayList<String>() {
            {
                add("http://localhost:8801");
                add("http://localhost:8802");
            }
        };
        System.out.println(GATEWAY_NAME + " " + GATEWAY_VERSION + " starting ...");

        // 访问8888， 代理到别的端口：8801/8802
        HttpInboundServer server = new HttpInboundServer(port, proxyServices);

        System.out.println(GATEWAY_NAME + " " + GATEWAY_VERSION + " started at http://localhost:" + port + " for server" + server.toString());

        try {
            server.run();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
